﻿using CommonType;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S_Gridding.Domains.FoundGridding;
using S_Gridding.Read.Api.Application.Commands;
using S_Userinfor.Domains;

namespace S_Gridding.Read.Api.Controllers
{
    /// <summary>
    /// 单元网格管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CellgridController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public CellgridController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 单元网格列表
        /// </summary>
        /// <param name="commons"></param>
        /// <returns></returns>
        [HttpGet] 
        public async Task<PageResule<Cellgrid>> PageShowCottage([FromQuery] CellgridShowCommands commons)
        {
            return await _mediator.Send(commons);
        }
        /// <summary>
        /// 单元网格反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<object> FanCity([FromQuery] CellgridUpdCommands command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 所属区域列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult AreaType()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<Area>())
            {
                list.Add(new
                {
                    value = item,
                    text = item.ToString()
                });
            }
            return Ok(list);
        }
    }
}
